<script>
import isArray from "lodash/isArray"
export default {
  methods: {
    isGranted(role) {
      if(!role || role.length==0){
        // 没角色要求的默认不验证
        return true
      }
      let user_own_roles = this.$store.state.role.userSystemRoles
      // powerful admin user to access all contents
      if (user_own_roles.includes('admin')) {
       return true
      } else {
        if(isArray(role)){
          for(const r of role){
            if(user_own_roles.includes(r)){
              return true
            }else if(r==="UCD_USER" && this.currentUser.type=="W"){
							return true
						}else{
							continue
						}
          }
          return false
        }
        else{
					if(role==="UCD_USER" && this.currentUser.type=="W"){
						return true
					}else{
						return user_own_roles.includes(role)
					}   
        }
      }
    }
  }
}
</script>
